/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package client.dal;

import client.entity.LevelJob;
import java.util.ArrayList;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import util.HibernateUtil;

/**
 *
 * @author mrlucky
 */
public class LevelJobDAL {

    public LevelJobDAL() {
    }
    
    public ArrayList<LevelJob> loadLevelJob()
    {
        SessionFactory sf = HibernateUtil.getSessionFactory();
        Session ss = sf.openSession();
        ss.beginTransaction().begin();
        ArrayList<LevelJob> list = (ArrayList<LevelJob>) ss.createQuery("from LevelJob lj").list();
        ss.beginTransaction().commit();
        ss.close();
        return list;
    }
    
    public LevelJob getLevelJobByID(String lvID)
    {
        SessionFactory sf = HibernateUtil.getSessionFactory();
        Session ss = sf.openSession();
        ss.beginTransaction().begin();
        LevelJob lv = (LevelJob) ss.createQuery("from LevelJob lj where lj.id ="+lvID).uniqueResult();
        ss.beginTransaction().commit();
        ss.close();
        return lv;
    }
}
